/**
 * RandomDitribAlgo class 
 * 
 * 
 * @created 2007-04-17
 * @author csamson
 */

package objects.distribution;

import objects.*;
import kernel.*;
import java.lang.Math;
import java.util.*;
import java.awt.event.*;
import java.awt.*;
import java.awt.geom.*;


public class RandomDistribAlgo extends DistributionAlgo{

    public RandomDistribAlgo(){
    }


    /**
     *The random distribution constructor
     *
     * @param x the upperLeft corner X coordonate of the sensorNetwork
     * @param y the upperLeft corner Y coordonate of the sensorNetwork
     * @param w the sensorNetwork width
     * @param h the sensorNetwork height
     * @param s the number of sensor in the sensorNetwork
     *
     */
    public RandomDistribAlgo(double x, double y, double w, double h, int s){
	_ulX = x;
	_ulY = y;
	_width = w;
	_height = h;

	_sensorAmount = s;
    }


    /**
     * @return the algorithm name
     */
    public String getName(){
	return "RandomDistribAlgo";
    }
    

    /**
     * @return the point table used to place the sensors
     */
    public Point2D[] distribute(){
	Point2D[] result = new Point2D[_sensorAmount];
	Random rand = new Random();
	for(int i=0;i<result.length;i++){
	    double x = _ulX + (rand.nextDouble() * _width);
	    double y = _ulY + (rand.nextDouble() * _height);
	    result[i] = new Point2D.Double(x,y);
	}
	return result;

    }

}
